/*
 * @Author: huangtianyang 916072572@qq.com
 * @Date: 2022-12-20 16:01:53
 * @LastEditors: huangtianyang
 * @LastEditTime: 2023-07-26 18:01:06
 * @FilePath: \cxl-admin\src\apis\company\index.ts
 */
import axios from '../../axios/index'

/**
 * 定义企业审核参数
 */
interface AuditData {
    auditStatus: number
    id: string
    remark?: string
}

/**
 * 企业审核
 * @param data
 * @returns
 */
export const companyAudit = (data: AuditData) => {
    return axios({
        method: 'post',
        url: '/api/system/company/audit',
        data
    })
}

/**
 * 企业审核详情
 * @param id
 * @returns
 */
export const companyDetailed = (id: string) => {
    return axios({
        method: 'get',
        url: '/api/system/company/audit/detail',
        params: { id }
    })
}

/**
 * 定义查询审核企业参数
 */
export interface searchAuditParamsInterface {
    auditStatus?: number //审核状态(0.待审核；1.通过；2.未通过)
    companyName?: string //公司名
    current: number
    phone?: string
    size: number
}

/**
 * 企业审核列表
 * @param params
 * @returns
 */
export const companyAuditList = (params: searchAuditParamsInterface) => {
    return axios({
        method: 'get',
        url: '/api/system/company/audit/list',
        params
    })
}

export interface searchCompanyParamsInterface {
    companyParam?: string //公司名|编号
    current: number
    size: number
}

/**
 * 企业选择器 参数 移除（ 审核| 电话） 等参数
 * @param params
 * @returns
 */
export const selectCompany = (params: searchCompanyParamsInterface) => {
    return axios({
        method: 'get',
        url: '/api/system/company/select',
        params
    })
}

export interface companyAdminListInterface {
    current: number
    phone?: string
    size: number
    companyId?: string
    status?: number
}

/**
 * 查询企业管理者账号
 * @param params
 * @returns
 */
export const getCompanyAdminList = (params: companyAdminListInterface) => {
    return axios({
        method: 'get',
        url: '/api/system/admin/company-admin-list',
        params
    })
}

/**
 * 设置免费次数
 * @param companyId
 * @param crashSystemFreeCount //免费试用次数 出险
 * @param maintenanceSystemFreeCount //免费试用次数 维保车况
 * @returns
 */
export const setSystemFreeCount = (companyId: string, freeCountMap: object) => {
    return axios({
        method: 'post',
        url: '/api/mall/company/store/set-system-free-count',
        data: {
            companyId,
            freeCountMap
        }
    })
}
/**
 * 查询公司免费次数
 * @param companyIds //?companylds=1,2,55
 * @returns
 */
export const getCompanyFreeCount = (companyIds: string) => {
    return axios({
        method: 'get',
        url: '/api/mall/company/store/query-company-free-count',
        params: {
            companyIds: companyIds
        }
    })
}

/**
 * 删除管理员账号
 * @param id
 * @returns
 */
export const deleteAdmin = (id: string) => {
    return axios({
        method: 'post',
        url: '/api/system/admin/delete',
        data: {
            id
        }
    })
}

/**
 * 企业禁用
 * @param id
 * @returns
 */
export const enabledCompany = (companyId: string, isEnabled: boolean) => {
    return axios({
        method: 'put',
        url: '/api/system/company/enabled',
        params: {
            companyId,
            isEnabled
        }
    })
}
